package com.ace.user.common.http;

import com.alibaba.fastjson.JSONObject;
import com.ace.user.common.bean.RequestDTO;
import com.ace.user.common.bean.ResponseDTO;
import feign.Headers;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * 第三方token服务
 *
 */
@FeignClient(name = "token-service", url = "${feign.client.config.token-service.url}",fallback = FeignTokenFailure.class)
@Headers({"Content-Type: application/json;charset=UTF-8"})
public interface FeignTokenService {
	/**
	 * 添加
	 * @return
	 */
	@PutMapping(value="/api/v1/token/add",consumes = MediaType.APPLICATION_JSON_VALUE)
	JSONObject addToken(@RequestBody RequestDTO paramDTO);

	/**
	 * testMethod
	 * @return
	 */
	@GetMapping(value="/api/v1/token/test/{type}",consumes = MediaType.APPLICATION_JSON_VALUE)
	ResponseDTO testMethod(@PathVariable( "type" ) String type);

	/**
     * 删除token
     * @param paramDTO
     */
    @DeleteMapping(value="/api/v1/token/uid",consumes = MediaType.APPLICATION_JSON_VALUE)
    void deleteTokenByUserId(@RequestBody RequestDTO paramDTO);

    /**
	 * 校验token
	 * @param param
	 * @return
	 */
	@PostMapping(value="/api/v1/token/check",consumes = MediaType.APPLICATION_JSON_VALUE)
	ResponseDTO checkToken( @RequestBody RequestDTO param);


	/**
	 * 添加
	 * @param uid
	 * @param type
	 * @return
	 */
	@PutMapping(value="/api/v1/token/user/{uid}/type/{type}",consumes = MediaType.APPLICATION_JSON_VALUE)
	String addToken(@PathVariable( "uid" ) String uid, @PathVariable( "type" ) String type,
					@RequestBody RequestDTO paramDTO);
}
